﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<div class="div_RegisterCode">
    <input type="hidden" id="Hidden_NamePage" value="UNLOCK PAGE" />
    <div id="div_RegisterCode_Carrier" class="div_RegisterCode_ChooseInformation">
        <table>
            <tr>
                <td>
                    Please choose carrier
                </td>
            </tr>
            <tr>
                <td>
                    <%= Html.DropDownList("ddl_Carrier", (SelectList)ViewData["lstCarrier"], new {onchange ="ChangeInfomation()" })%>
                </td>
            </tr>
            <tr>
                <td class="Height10">
                </td>
            </tr>
            <tr>
                <td>
                    Please choose brand
                </td>
            </tr>
            <tr>
                <td>
                    <%= Html.DropDownList("ddl_Brand", (SelectList)ViewData["lstBrand"], new { onchange = "ChangeInfomation()" })%>
                </td>
            </tr>
            <tr>
                <td class="Height10">
                </td>
            </tr>
            <tr>
                <td>
                    Please choose model
                </td>
            </tr>
            <tr>
                <td>
                    <%= Html.DropDownList("ddl_Model", (SelectList)ViewData["lstModel"], new { onchange = "ChangeInfomation()" })%>
                </td>
            </tr>
        </table>
    </div>
    <div id="div_RegisterCode_PhoneInfomation" style="display: none" class="div_RegisterCode_ChooseInformation">
        <table>
            <tr>
                <td>
                    Phone Imei
                </td>
            </tr>
            <tr>
                <td>
                    <input type="text" id="txt_Imei" onkeyup="changeTextInfomation()" />
                </td>
            </tr>
            <tr>
                <td class="Height10">
                </td>
            </tr>
            <tr>
                <td>
                    Your Email
                </td>
            </tr>
            <tr>
                <td>
                    <input type="text" id="txt_Email" onkeyup="changeTextInfomation()" />
                </td>
            </tr>
        </table>
    </div>
    <div id="div_RegisterCode_Register" style="display: none" class="div_RegisterCode_ChooseInformationRight">
        <table>
            <tr>
                <td>
                <br /> <br />
                    <input type="button" id="btn_RegisterCode" class="ButtonRegister" value="Register Code" />
                </td>
            </tr>
        </table>
    </div>
</div>
<script type="text/javascript">
    $("#Hidden_NamePage").ready(function () {
        var textPageName = $("#Hidden_NamePage").val();
        $("#Master_Div_ShowPageName_ID").html(textPageName);
    })
    function ChangeInfomation() {

        var Carrier = $("#ddl_Carrier").val();
        var Brand = $("#ddl_Brand").val();
        var Model = $("#ddl_Model").val();

        if (Model != "00000000-0000-0000-0000-000000000000"
        && Brand != "00000000-0000-0000-0000-000000000000"
        && Model != "00000000-0000-0000-0000-000000000000") {
            $("#div_RegisterCode_Carrier").animate({
               
                left: "-=300px"
            }, 1500);

            var myVar = setTimeout(function () { ShowDivSlowly("div_RegisterCode_PhoneInfomation") }, 1200);


        }


    }
    function ShowDivSlowly(DivID) {
        $("#" + DivID).show("slow");
    }
    function changeTextInfomation(DivID) {
        var Imei = $("#txt_Imei").val();
        var Email = $("#txt_Email").val();
        var isValid = checkValidRegisterCode(Imei, Email)
        if (isValid == true) {
            
            ShowDivSlowly("div_RegisterCode_Register");
        }

    }
    function checkValidRegisterCode(Imei, Email) {
       
        if (Imei == "" || Email == "") {
            return false;
        }
        if (validateEmail(Email) == true) {
            return true;
        }
        return false;
    }
    function validateEmail(email) {
        var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email);
    } 

</script>
